new Vue({
    el: '#app',
    data() {
        return {
            form: {
                SQLSerialNumber: "P_business_expert_problem_detail_1",
                PaginationNumber: 1,//页数
                RowAmount: 20,//每页数据条数
                Condition: '',
                ExtensionCondition: '',
                Sort: 1,
                Expert_Poblem_SerialNumber: '',
            },
            data:{},
            total: 0,
            tableData: [],	//表格数据
            Picture_URL:[],
            message:'',
            loading: false,
        }
    },
    mounted() {
        if (getQueryObject().Expert_Poblem_SerialNumber && getQueryObject().Expert_Poblem_SerialNumber != "undefined") {
            this.form.Expert_Poblem_SerialNumber = getQueryObject().Expert_Poblem_SerialNumber;
            this.getData(this.form);
            this.getList(this.form);//前端分页
            this.getPic(this.form);
        }
    },
    methods: {
        onSerach() {			//查询方法
            this.form.PaginationNumber = 1;
            this.getData(this.form)
        },
        handleBack(){
            window.history.go(-1);
        },
        getData(form) {
            const that = this;
            let data = deepClone(form);
            data.Condition = window.btoa(unescape(encodeURIComponent(form.Expert_Poblem_SerialNumber)));
            let sql = "";
            if (form.Sort) {
                sql = sql + " ORDER BY business_expert_problem_detail.Operation_Datetime\r\n";
            } else {
                sql = sql + " ORDER BY business_expert_problem_detail.Operation_Datetime DESC\r\n";
            }
            data.ExtensionCondition = window.btoa(unescape(encodeURIComponent(sql)));
            $.ajax({
                url: `${BASE_URL2}/salesOrder/queryShoppingTrolleyBySQLSerialNumber`,
                type: 'POST',
                data,
                success: function (data) {
                    that.tableData = data;
                },
                dataType: "json"
            });
        },
        getList(form) {//换页方法
            const that = this
            let sql = "where 1=1\r\n";
            if (form.Expert_Poblem_SerialNumber) {
                sql = sql + "and business_expert_problem.Expert_Poblem_SerialNumber='" + form.Expert_Poblem_SerialNumber + "'\r\n";
            }
            $.ajax({
                url: `${BASE_URL2}/salesOrder/queryShoppingTrolleyBySQLSerialNumber`,
                type: 'POST',
                data:{
                    SQLSerialNumber: "P_business_expert_problem",
                    Condition: '',
                    ExtensionCondition: ExtensionCondition = window.btoa(unescape(encodeURIComponent(sql))),
                },
                success: function (Result) {
                    if (Result.length==1) {
                        that.data = Result[0];
                    }
                },
                dataType: "json"
            });
        },
        getPic(form) {//换页方法
            const that = this
            $.ajax({
                url: `${BASE_URL2}/salesOrder/queryShoppingTrolleyByTableName`,
                type: 'GET',
                data:{
                    TableName: "business_expert_problem_pic",
                    Condition: "Expert_Poblem_SerialNumber='"+form.Expert_Poblem_SerialNumber+"'",
                },
                success: function (Result) {
                    that.Picture_URL = Result;
                },
                dataType: "json"
            });
        },
        submitForm(){//提交消息
            const that =this;
            if (this.message) {
                $.ajax({
                    url: `${BASE_URL2}/clientOperation/generalSaveForClient`,
                    type: 'POST',
                    data:{
                        Data:JSON.stringify({
                            Add:{
                                business_expert_problem_detail:[{
                                    Expert_Problem_Detail_SerialNumber:'',
                                    Expert_Problem_SerialNumber:this.form.Expert_Poblem_SerialNumber,
                                    problem:this.message
                                }]
                            }
                        })
                    },
                    success: function (Result) {
                        if (Result.Status == 'success') {
                            that.message = '';
                            that.getData(that.form);
                        }
                    },
                    dataType: "json"
                });
            }
        }
    },
})